/*
* @Author: yanyanru
* @Date: 2018/4/13
* @description: 管理费用
*/
<template>
  <div class='custom-box m-t-20 p-20'>
      <div class="custom-title">
        <h3 class="m-r-10">管理费用</h3>
          <div class='m-l-10'><el-button type="primary" size='mini' round @click="saveFundCost">保存</el-button></div>
      </div>
      <el-form label-width="90px" class="m-t-20">
        <el-row>
            <el-col :span="12">
                <el-row>
                    <el-col :span='12'>
                        <el-form-item label="管理费">
                            <el-input  style="width:100%" v-model="comFundCost.cost">
                                <template slot="append">%</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span='12'>
                        <el-form-item label="优先回报率">
                            <el-input  style="width:100%" v-model="comFundCost.priorityReturn">
                                <template slot="append">%</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span='12'>
                        <el-form-item label="分红">
                            <el-input style="width:100%" v-model="comFundCost.shareDividends">
                                <template slot="append">%</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span='12'>
                        <el-form-item label="GP承诺金额">
                            <el-input  style="width:100%" v-model="comFundCost.commitmentAmount">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-form-item label="投资周期">
                        <el-input style="width:100%" v-model="comFundCost.cycle">
                            <template slot="append">年</template>
                        </el-input>
                    </el-form-item>
                </el-row>
            </el-col>
            <el-col :span='12'>
                <el-form-item label="中文描述">
                    <el-input
                        v-model="comFundCost.description"
                        type="textarea"
                        placeholder="请输入内容"
                        :maxlength="2000"
                        resize="none"
                    ></el-input>
                </el-form-item>
            </el-col>
        </el-row>
    </el-form>
  </div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Watch, Prop } from 'vue-property-decorator';
import ComFundService from '../../../../../service/subject/company/fund-info/index';
import { ComFundCostDto, } from '../../../../../api/Interface';
@Component({
  components: { }
})
export default class BasicInfo extends Vue {
    @Prop({})
    public fundId: number;
    // 初始化数据 相当于data
    public msg: string = '122';
    public comFundCost: ComFundCostDto = {} as ComFundCostDto;

  
    // refs
    public $refs: { };

    // watch
    @Watch('fundId')
    public onChildChanged(val: number, oldVal: number) {
        this.fundId = val;
    }
  public created() {
    this.getFundCost(Number(this.$route.params.itemId));
  }
  // 根据id获取管理费用
  public async getFundCost(id: number) {
      const res = await ComFundService.getComFundCostById(id);
      this.comFundCost = res.data;
  }
  // 保存管理费用
    public async saveFundCost() {
        this.comFundCost.companyId = Number(this.$route.params.itemId);
        this.comFundCost.fundId = this.fundId;
        if (!this.comFundCost.id) { //添加
            const { resCode } = await ComFundService.saveComFundCost(this.comFundCost);
            if (resCode === '0') {
                this.$message.success('添加成功');
                this.getFundCost(Number(this.$route.params.itemId));
            }
        } else { //修改
            const { resCode } = await ComFundService.updateComFundCost(this.comFundCost);
            if (resCode === '0') {
                this.$message.success('修改成功');
            }
        }        
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>